Skip to content

Fix sending heroes in SSS when m.room.name=""#19468

Open
frebib wants to merge 1 commit intoelement-hq:developfrom
frebib:frebib/fix-19447
Open

Fix sending heroes in SSS when m.room.name=""#19468
frebib wants to merge 1 commit intoelement-hq:developfrom
frebib:frebib/fix-19447

Conversation

@frebib
Copy link
Copy Markdown
Contributor

@frebib frebib commented Feb 16, 2026

As per the spec, a room with m.room.name value that is absent, null or empty should be treated as if there is no m.room.name event at all: https://spec.matrix.org/v1.17/client-server-api/#mroomname

This fetches the full m.room.name event and checks the content.name instead of only checking the existence of the m.room.name event. This results in correctly sending heroes for those rooms.

Fixes: #19447

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

@frebib frebib requested a review from a team as a code owner February 16, 2026 01:28
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 16, 2026

CLA assistant check
All committers have signed the CLA.

@frebib frebib force-pushed the frebib/fix-19447 branch 2 times, most recently from 5792708 to bf1daac Compare February 16, 2026 01:40
@frebib
Copy link
Copy Markdown
Contributor Author

frebib commented Feb 16, 2026

Confirmed that this fixes the issue for me, although I'd like some input on exactly how to implement this, perhaps. I fear that the extra round-trip(s) to the database on every sync request aren't the most optimal way to implement this

As per the spec, a room with m.room.name value that is absent, null or
empty should be treated as if there is no m.room.name event at all:
https://spec.matrix.org/v1.17/client-server-api/#mroomname

This fetches the full m.room.name event and checks the content.name
instead of only checking the existence of the m.room.name event. This
results in correctly sending heroes for those rooms.

Fixes: element-hq#19447
Signed-off-by: Joe Groocock <me@frebib.net>
]
meta_room_state = list(hero_room_state)
if initial or name_changed:
meta_room_state.append((EventTypes.Name, ""))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that this isn't needed now. I wasn't sure whether it was safe to remove or not though

Copy link
Copy Markdown
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really sorry for the long wait.
This bug fix seems correct to me, so thanks for sending it in.
If you're happy to take a look, I'd be grateful for the tweak to avoid this op when it's not needed.


# TODO: Should we also check for `EventTypes.CanonicalAlias`
# (`m.room.canonical_alias`) as a fallback for the room name? see
# https://github.com/matrix-org/matrix-spec-proposals/pull/3575#discussion_r1671260153
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also link to https://github.com/matrix-org/matrix-spec-proposals/pull/4186/changes#r2860107511 which I just opened as an equivalent thread on the non-obsolete MSC.

I think you're currently correct in not using the canonical alias

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I just realised this is not your comment, you just moved it, sorry & thanks)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll update the comment link

@@ -0,0 +1 @@
Fix bug in sync that could prevent user avatars from showing if the room had an empty name.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fix bug in sync that could prevent user avatars from showing if the room had an empty name.
Fix a bug in [MSC4186: Simplified Sliding Sync](https://github.com/matrix-org/matrix-spec-proposals/pull/4186) that could prevent user avatars from showing if the room had an empty name.

I know it's nitpicky but useful for people reading to understand this is not oldschool sync.

membership_changed = False
name_changed = False
avatar_changed = False
if initial:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, sorry to be a pest but I think it'd be nice to keep the performance properties of the old code:
we didn't get the m.room.name state unless the sync was initial.

I think this is getting run once per room on every sync so it feels important enough to at least try.

Instead of name_event_id: str | None how about pulling out the full event name_event: EventBase | None

I suspect we want to retrieve the name_event in two conditions:

  • initial
  • or name_changed (L908 / R899)

Also thinking that we need to properly handle the case where the room name is initially "My Room" and then someone changes it to "" at which point we need to start using heroes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for keeping the performance here if at all possible. The code is rather complex and I'm scared of introducing a regression 😆

Also thinking that we need to properly handle the case where the room name is initially "My Room" and then someone changes it to "" at which point we need to start using heroes.

Given that sync is stateless, I'm not sure if there's a way to do this without unconditionally fetching this event every time to look at the content to discern whether we need to send heroes or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rooms with m.room.name="" don't get heroes sent in MSC4186/sliding sync

4 participants